<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .a1{
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div class="a1">

    </div>
    <button class="b1">小于150 变蓝色</button>
    <button class="b2">变回300</button>
    <script>
        let b1=document.getElementsByClassName("b1")[0]
        let b2=document.getElementsByClassName("b2")[0]
        let d=document.querySelector("div")
        let b=300
        b1.onclick=function(){
            let c=setInterval(function(){
                b--
                if(b<150){
                    d.style="background-color:blue"
                    clearInterval(c)
                }
            },1)
        }
        b2.onclick=function(){
            let c=setInterval(function(){
                b++
                if(b>150){
                    console.log(1);
                    clearInterval(c)
                }
            },1)
        }
    </script>
</body>
</html>